//数据库集合的相关配置
//1.定义数据集合的结构：定义出集合中数据有哪些属性，属性的值是什么类型
const mongoose = require('mongoose');
const {
    Schema,
    model
} = require('mongoose');
// const { route } = require('./routes/index');
const parkingsSchema = new Schema({
    address: String,
    number: String,
    property: String,
    cycle: String,
    price: String,
    state: {
        type: Number,
        default: 1
    },
    telephone: {
        type: String,
        default: 15236254785
    },
    lessorsId: {
        type: mongoose.Schema.Types.ObjectId, //把数据类型设置为_Id类型
        ref: 'lessorsModel', //把数据和lessorssModel关联起来了
        //default:1526542642415
    },
    delete: {
        type: Boolean,
        default: false
    },
    tenantsId: {
        type: mongoose.Schema.Types.ObjectId, //把数据类型设置为_Id类型
        ref: 'tenantsModel', //把数据和tenantssModel关联起来了
        //default:1526542642415
    },
    rent: {
        type: Number,
        default: 1
    },
    ordersId: [{
        type: Schema.Types.ObjectId,
        ref: 'ordersModel',
    }],
}, {
    versionKey: false
}) //mongooes的默认加的版本号，不要
//2.定义数据集合的模型：将Schema和数据库中的集合关联起来
//model('模型名称',parkingsSchema,'数据库中的集合名称');
const parkingsModel = model('parkingsModel', parkingsSchema, 'parkings');
module.exports.parkingsModel = parkingsModel;